//index.js  
//获取应用实例  
var app = getApp()
Page({
  data: {
    motto: 'Hello World',
    userInfo: {},
    team:0,
    tixina:0,
    txdone:0,
    txuse:0,
    order:0,
    fx:0,
    leader:''
  },
  testlogin: function(){
    var that = this
    app.getUserInfo(function (userInfo) {
      //更新数据  
      that.setData({
        userInfo: userInfo
      })
    })
  },
  shouye:function() {
    wx.switchTab({
      url: '../index/index',
      success: function (e) {
        var page = getCurrentPages().pop();
        if (page == undefined || page == null) return;
        page.onLoad();
      }
    })
  },
  onLoad: function () {
    console.log('onLoad')
    var that = this
    //调用应用实例的方法获取全局数据  
    app.getUserInfo(function (userInfo) {
      //更新数据  
      that.setData({
        userInfo: userInfo
      })
    })
    wx.request({
      url: app.d.ceshiUrl + '/Api/Distribution/getAllInfo',
      method: 'post',
      data: {
        userId: app.d.userId,
      },
      header: {
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        console.log('team', res.data.data.team)
        that.setData({
          team: res.data.data.team,
          tixian:res.data.data.tixian,
          txdone:res.data.data.txdone,
          txuse:res.data.data.txuse,
          order:res.data.data.order,
          fx:res.data.data.fx,
          leader:res.data.data.leader
        });
      }
    })
}
})